package com.design.movieticket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.design.movieticket.dto.DashBoardDto;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DashBoardMapper extends BaseMapper<DashBoardDto> {
    @Select("select sum(order_pay)\n" +
            "from orders a\n" +
            "left join movie_arrange b\n" +
            "on a.movie_arrange_id = b.id\n" +
            "left join cinema c\n" +
            "on c.id = a.cinema_id\n" +
            "where b.end_time BETWEEN #{dateStart} and #{dateEnd} and c.principal = #{username}")
    String getLine(String username,String dateStart,String dateEnd);

    @Select("select sum(order_pay)\n" +
            "from orders a\n" +
            "left join movie_arrange b\n" +
            "on a.movie_arrange_id = b.id\n" +
            "left join cinema c\n" +
            "on c.id = a.cinema_id\n" +
            "where b.end_time BETWEEN #{dateStart} and #{dateEnd} and c.principal = #{username}")
    String getLineByAdmin(String username,String dateStart,String dateEnd);

    @Select("select sum(order_pay)\n" +
            "from orders a\n" +
            "left join movie_arrange b\n" +
            "on a.movie_arrange_id = b.id\n" +
            "left join cinema c\n" +
            "on c.id = a.cinema_id\n" +
            "where b.end_time BETWEEN #{dateStart} and #{dateEnd}")
    String getLineBySuperAdmin(String username,String dateStart,String dateEnd);

    @Select("select count(level),level\n" +
            "from user where del_flag=0\n" +
            "GROUP BY level")
    List<String> getCircle();

    @Select("SELECT COUNT(id) FROM movie\n" +
            "UNION ALL\n" +
            "SELECT COUNT(id) from user\n" +
            "union all\n" +
            "select sum(order_pay) from orders\n" +
            "union all\n" +
            "select SUM(order_pay) from orders a left join movie_arrange b \n" +
            "on a.movie_arrange_id = b.id where b.end_time BETWEEN '2023-05-06 00:00:00' and '2023-05-06 23:59:59'\n" +
            "union all\n" +
            "select count(a.id) from orders a left join movie_arrange b \n" +
            "on a.movie_arrange_id = b.id where b.end_time BETWEEN '2023-05-06 00:00:00' and '2023-05-06 23:59:59'")
    List<String> getData();
}
